import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";


type homeResult = {
  page: any;
  result: any
};


export type UserResult = {
  // success: boolean;
  // data: {
  //   /** 用户名 */
  //   username: string;
  //   /** 当前登陆用户的角色 */
  //   roles: Array<string>;
  //   /** `token` */
  //   accessToken: string;
  //   /** 用于调用刷新`accessToken`的接口时所需的`token` */
  //   refreshToken: string;
  //   /** `accessToken`的过期时间（格式'xxxx/xx/xx xx:xx:xx'） */
  //   expires: Date;
  // };
  page: any
  result: {
    id: string | number;
    token: string;
    account: string;
    name: string;

  }
};

export type RefreshTokenResult = {
  success: boolean;
  data: {
    /** `token` */
    accessToken: string;
    /** 用于调用刷新`accessToken`的接口时所需的`token` */
    refreshToken: string;
    /** `accessToken`的过期时间（格式'xxxx/xx/xx xx:xx:xx'） */
    expires: Date;
  };
};

/** 个人信息查询 */
export const userperinfo = (userid) => {
  return http.request<homeResult>("get", baseUrlApi(`/api/backend/user/perinfo/${userid}`));
};


/** 新增文章池类型字典 */
export const articleinsertpondstype = (data?: object) => {
  return http.request<homeResult>("post", baseUrlApi("/api/backend/article/insertpondstype"), { data });
};

/** 文章池类型列表 */
export const selpondstypepage = (data?: object) => {
  return http.request<homeResult>("post", baseUrlApi("/api/backend/article/selpondstypepage"), { data });
};

/** 修改文章池类型 */
export const updatepondstype = (data?: object) => {
  return http.request<homeResult>("post", baseUrlApi("/api/backend/article/updatepondstype"), { data });
};


/** 删除文章池类型字典 */
export const delpondstype = (userid?: string | number) => {
  return http.request<homeResult>("delete", baseUrlApi(`/api/backend/article/delpondstype/${userid}`));
};

/** 文章列表分页查询 */
export const selarticlelist = (data?: object) => {
  return http.request<homeResult>("post", baseUrlApi("/api/backend/article/selarticlelist"), { data });
};


/** 修改文章数据 */
export const updatearticle = (data?: object) => {
  return http.request<homeResult>("post", baseUrlApi("/api/backend/article/updatearticle"), { data });
};

/** 新增文章数据 */
export const insertarticle = (data?: object) => {
  return http.request<homeResult>("post", baseUrlApi("/api/backend/article/insertarticle"), { data });
};


/** 删除文章池类型字典 */
export const delarticle = (userid?: string | number) => {
  return http.request<homeResult>("delete", baseUrlApi(`/api/backend/article/delarticle/${userid}`));
};